<?php

require_once ($DOCUMENT_ROOT . '/includes/functions.php');

session_start ();

if (valid_user ())
{
	$inheader = "<script type='text/javascript' src='/js/bobcat.js'></script>";
	do_header ("Leave Feedback", $inheader);
	do_menu ();

	if ($submit)
	{
		db_connect ();
		
		$name = $_SESSION['valid_user'];
		$comment = addslashes ($comment);
		if ($anon != 1)
		{
			$anon = 0;
		}

		$query = "INSERT INTO feedback SET name='$name',
										anon='$anon',
										title='$title',
										comment='$comment',
										date=CURDATE(), 
										pending=1";
										
		$result = mysql_query($query)
			or report_error ($PHP_SELF, mysql_error (), "feedback submission failed", $_SESSION['valid_user']);
			
		echo "<p>Your feedback has been submitted.</p><p>Thank you for helping the project grow and improve</p>";
		do_url ('/list.php', 'Go to list');
	}
	else
	{
?>
<form name="form1" method="post" action="" onSubmit="return verifyReview (this);">
   <h1>Feedback Form</h1>
   <p>Submit questions or comments that you think could help improve the project, 
   ask the author a question, apply to be an admin here, or just leave general feedback. </p>
   <h6>note: to rate and review an instructor, go to the <a href="/list.php">list</a> and click on the instructor's name.</h6>
   <h3>Title:</h3>
   <p>
     <input type="text" name="title">
</p>
   <h3>Comment:</h3>
  <p><textarea name="comment"></textarea></p>
  <p>
    <label>
    <input name="anon" type="radio" value="0" checked> 
    I want someone to follow up on my feedback via email </label>
    <br />
    <label>
    <input type="radio" name="anon" value="1"> 
    I do not want to be contacted about my feedback </label>
  </p>
  <p><input type="submit" name="submit" value="Submit">
  <input type="reset" name="reset" value="Reset"></p>
</form>
<?php		
	}
do_footer ();
}
?>